/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Others;

import java.io.UnsupportedEncodingException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

/**
 *
 * @author Neves
 */
public class MD5Convertor {

    public String Md5ConversionToString(String s) throws NoSuchAlgorithmException, UnsupportedEncodingException {
        byte[] bytesOfMessage = s.getBytes("UTF-8");

        MessageDigest md = MessageDigest.getInstance("MD5");
        byte[] thedigest = md.digest(bytesOfMessage);

        String aux = new String(thedigest);

        return aux;
    }

    public byte[] Md5ConversionToByteArray(String s) throws NoSuchAlgorithmException, UnsupportedEncodingException {
        byte[] bytesOfMessage = s.getBytes("UTF-8");

        MessageDigest md = MessageDigest.getInstance("MD5");
        byte[] thedigest = md.digest(bytesOfMessage);

        return thedigest;
    }
}
